package models

import "gorm.io/gorm"

type News struct {
	gorm.Model
	Title   string  `json:"title" gorm:"type:varchar(255)"`
	Author  string  `json:"author" gorm:"type:varchar(255)"`
	Img     string  `json:"img" gorm:"type:varchar(255)"`
	CateId  uint    `json:"cateId" gorm:"type:int(10)"`
	Status  string  `json:"status" gorm:"type:varchar(255)"`
	NewType NewType `gorm:"foreignKey:CateId"`
}

type NewType struct {
	gorm.Model
	Name string `json:"name"`
}

type User struct {
	gorm.Model
	Name     string `json:"name" gorm:"type:varchar(255)"`
	Password string `json:"password" gorm:"type:varchar(255)"`
}

type Comment struct {
	gorm.Model
	Author string `json:"author" gorm:"type:varchar(255)"`
	NewsId uint   `json:"newsId" gorm:"type:int(10)"`
	UserId uint   `json:"userId" gorm:"type:int(10)"`
	News   News   `gorm:"foreignKey:NewsId"`
	User   User   `gorm:"foreignKey:UserId"`
}

type Collection struct {
	gorm.Model
	NewId  uint `json:"newId"  gorm:"type:int(10)"`
	UserId uint `json:"UserId" gorm:"type:int(10)"`
	News   News `gorm:"foreignKey:NewId"`
	User   User `gorm:"foreignKey:UserId"`
}
